﻿using Pigg.Contracts;

namespace Pigg.Data
{
    public class PiggUow : IPiggUow
    {
        private readonly IModelReader _modelReader;
        private readonly IPageCommands _pageCommands;
        private readonly PiggDbContext _db;

        public PiggUow(IDatabaseFactory databaseFactory)
        {
            _db = databaseFactory.Get() as PiggDbContext;
            _modelReader = new ModelReader(databaseFactory);
            _pageCommands = new PageCommands(databaseFactory);
        }

        public void Save()
        {
            _db.SaveChanges();
        }

        public IModelReader ModelReader
        {
            get { return _modelReader; }
        }

        public IPageCommands PageCommands
        {
            get { return _pageCommands; }
        }
    }
}
